import { Module } from '@nestjs/common';
import { AuthService } from './auth.service';
import { AuthController } from './auth.controller';
import { JwtModule } from '@nestjs/jwt';
import { UsersModule } from '../users/users.module';
import { APP_GUARD } from '@nestjs/core';
import { AuthGuard } from './auth.guard';
import Constants from '../common/constants';
@Module({
  imports: [
    UsersModule,
    JwtModule.register({
      global: true,
      secret: Constants.Jwt_Secret as string,
      signOptions: { expiresIn: `${Constants.Jwt_Expire_Time}s` },
    }),
  ],
  controllers: [AuthController],
  providers: [
    AuthService,
    // 全局guard
    {
      provide: APP_GUARD,
      useClass: AuthGuard,
    },
  ],
  exports: [AuthService],
})
export class AuthModule {}
